package com.parkreport.report.service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.common.report.vo.ReportCountDataVO;
import com.common.report.vo.ReportDataVO;
import com.parkreport.vo.ReportParamVO;

public class TicketService {

	public static List<ReportCountDataVO> getTicketAll(ReportParamVO param){
		//获得数据
		
		
		//转义接口数据
		List<ReportCountDataVO> list = new ArrayList<ReportCountDataVO>();
		list.add(new ReportCountDataVO(new BigDecimal(4000L),"合计","仙女山"));
		list.add(new ReportCountDataVO(new BigDecimal(4000L),"合计","芙蓉洞"));
		return list;
	}
	
	public static List<ReportCountDataVO> getTicketGroup(ReportParamVO param){
		//获得数据
		
		
		//转义接口数据
		List<ReportCountDataVO> list = new ArrayList<ReportCountDataVO>();
		list.add(new ReportCountDataVO(new BigDecimal(1000L),"四川省","团队数-"+"仙女山"));
		list.add(new ReportCountDataVO(new BigDecimal(1000L),"重庆市","团队数-"+"芙蓉洞"));
		
		return list;
	}
	
	public static Map getTicketAllMap(ReportParamVO param){
		Map dataMap = new HashMap();
		List<ReportCountDataVO> list = getTicketAll(param);
		for (int i = 0; i < list.size(); i++) {
			ReportDataVO v = list.get(i);
			dataMap.put(v.getTitles()+"_"+v.getMents(), v.getCounts());
		}
		return dataMap;
	}
	
	//来源区、景区 散客数
	public static Map getTicketSubMap(ReportParamVO param){
		Map dataMap = new HashMap();
		List<ReportCountDataVO> list = getTicketAll(param);
		Map groupMap = getTicketGroupMap(param);
		for (int i = 0; i < list.size(); i++) {
			ReportCountDataVO v = list.get(i);
			String k = v.getTitles()+"_"+v.getMents();
			BigDecimal c = v.getCounts();
			BigDecimal g =  (BigDecimal)groupMap.get(k);
			BigDecimal count = new BigDecimal(1);
			if(c!=null&&g!=null&&c.longValue()!=0&&g.longValue()!=0){
				count=c.subtract(g);
			}
			dataMap.put(k, count);
		}
		return dataMap;
	}
	
	public static Map getTicketGroupMap(ReportParamVO param){
		Map dataMap = new HashMap();
		List<ReportCountDataVO> list = getTicketGroup(param);
		for (int i = 0; i < list.size(); i++) {
			ReportCountDataVO v = list.get(i);
			dataMap.put(v.getTitles()+"_"+v.getMents(), v.getCounts());
		}
		return dataMap;
	}
	
	public static Object getTicketAllCount(ReportParamVO param){
		
		List<ReportCountDataVO> list =getTicketAll(param);
		long ncount = 0L;
		for (int i = 0; i < list.size(); i++) {
			ReportCountDataVO l = list.get(i);
			System.out.println("count===="+l.getCounts());
			ncount+=l.getCounts().longValue();
		}
		return ncount;
	}
	
	public static Object getTicketGroupCount(ReportParamVO param){
		
		List<ReportCountDataVO> list =getTicketGroup(param);
		long ncount = 0L;
		for (int i = 0; i < list.size(); i++) {
			ReportCountDataVO l = list.get(i);
			ncount+=l.getCounts().longValue();
		}
		return ncount;
	}
	
}
